<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
	<ui:composition template="template/template.xhtml">
		<ui:define  name="page-title" >#{messages.relatorioMovimentos}</ui:define >
		<ui:define  name="center">
		
			<h:outputText styleClass="title" value="#{messages.relatorioMovimentos}"/>
        	<p:messages id="messages" autoUpdate="true" showSummary="true"/> 
        	
			<h:outputLabel value="#{messages.deposito}" for="deposito"/>
			<p:selectOneMenu id="deposito" value="#{relatorioController.deposito.id}" style="display: inline-block; vertical-align: middle;">  
                 <f:selectItem itemLabel="#{messages.seleccione}" itemValue="" /> 
                 <f:selectItems value="#{centroController.depositosArmazenamento}" var="deposito" itemValue="#{deposito.id}" itemLabel="#{deposito.id} - #{deposito.nome}" />  
                 <p:ajax update="@form" event="change"/>
            </p:selectOneMenu> 
            
            <h:outputLabel value="#{messages.material}" for="material"/>
 			<p:selectOneMenu id="material" value="#{relatorioController.material.id}" style="display: inline-block; vertical-align: middle;" >  
               	<f:selectItem itemLabel="#{messages.seleccione}" itemValue="" /> 
                <f:selectItems value="#{mercadoriaController.materials}" var="material" itemValue="#{material.id}" itemLabel="#{material.nome}" />  
          		<p:ajax update="@form" event="change"/>
           </p:selectOneMenu>
            
             	
          	<p:dataTable id="tabelaMovimentos" var="movimento" value="#{relatorioController.movimentos}"  
		                 paginator="true" rows="10"  paginatorPosition="bottom"
		                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "  
		                 rowsPerPageTemplate="5,10,15">  
		        
		        <p:column>  
		            <f:facet name="header">  
		                <h:outputText value="#{messages.id}" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.id}" />  
		        </p:column>  
		        
		        <p:column>  
		            <f:facet name="header">  
		                <h:outputText value="#{messages.centro}" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.deposito.centro.nome}" />  
		        </p:column>
		        
		        <p:column>  
		            <f:facet name="header">  
		                <h:outputText value="#{messages.deposito}" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.deposito.nome}" />  
		        </p:column>
		        
		        <p:column>  
		            <f:facet name="header">  
		                <h:outputText value="#{messages.material}" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.material.nome}" />  
		        </p:column>  
		  
		        <p:column>  
		            <f:facet name="header">  
		                <h:outputText value="#{messages.quantidade}" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.quantidade}" />  
		        </p:column>  
		  
		        <p:column>  
		            <f:facet name="header">  
		                <h:outputText value="Data Movimento" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.dataMovimento}" >  
		            	<f:convertDateTime pattern="#{messages.dateTimeFormat}" />
		            </h:outputText>  
		        </p:column> 
		     	
		     	<p:column>  
		            <f:facet name="header">  
		                <h:outputText value="#{messages.tipo}" />  
		            </f:facet>  
		            <h:outputText value="#{movimento.tipoMovimento}" />  
		        </p:column>
		     
		    </p:dataTable>
		    <p:commandButton value="#{messages.voltar}" action="relatorios" immediate="true" ajax="false" /> 
		    
		</ui:define >
	</ui:composition>
</html>